Two Separate Functions. 1) Saves user activity to a text file 2) Read text file, and explodes the data into an array

Instructions: LogUserActivity($LogFile, $Activity);

Call this function, where:
$LogFile is the link to the log file, needs to be created before use.
$Activity is what you want saved, eg Login: Furnfield

ReadUserActivity($LogFile);

Where $LogFile is the location of the log file you want read.

will give you the array $log.

$log[0] is the user IP
$log[1] is the Date and Time and Time Zone
$log[2] is the Action

======================================================

Function LogUserActivity($LogFile, $Activity){

$UserIp = $_SERVER['REMOTE_ADDR'];
$TimeRef = date('d-m-Y H:i T');

$Handle = fopen($LogFile, 'a'); 
$Data = $UserIp.'|'.$TimeRef.'|'.$Activity.'~';
fwrite($Handle, $Data); 
fclose($Handle); 

}

Function ReadUserActivity($LogFile){

GLOBAL $log;

$LogFile = file_get_contents($LogFile);

$ExplodedLogFile = explode("~", $LogFile);

$ArrayNum = count($ExplodedLogFile);

$i = 0;

while ( $i <= $ArrayNum ){
    
	$log[$i] = explode("|", $ExplodedLogFile[$i]);
	$i++;
}

}